# -*- coding: utf-8 -*-
# @Time    : 2021/3/19 13:54
# @Author  : mokez
# @Email   : 1569089678@qq.com
# @File    : 猜数字.py
# @Software: PyCharm
import random

game_num = random.randint(0, 100)
print(game_num)

for i in range(3):
    user_num = input("请猜一个0-100的数字：")
    if user_num.isdigit():
        user_num = int(user_num)
        if user_num == game_num:
            print("恭喜您猜中了")
            print(f"您花了{i + 1}次猜中")
            break
        elif user_num > game_num:
            print("您猜大了")
        elif user_num < game_num:
            print("您猜小了")
        print(f"您花了{i + 1}次机会，还有{2 - i}次机会")
        if (2 - i) == 0:
            print("次数已满")
    else:
        print("请重新输入：")
        continue
